// Commands.h : header file
//

#if !defined(AFX_COMMANDS_H__8549F5E1_E75A_4BE5_9A59_B192929065D4__INCLUDED_)
#define AFX_COMMANDS_H__8549F5E1_E75A_4BE5_9A59_B192929065D4__INCLUDED_

#include "TabBarsTypes.h"

//##ModelId=431C34CC032C
class CCommands : 
	public CComDualImpl<ICommands, &IID_ICommands, &LIBID_TabBars>, 
	public CComObjectRoot,
	public CComCoClass<CCommands, &CLSID_Commands>
{
protected:
	//##ModelId=431C34CC03C9
	IApplication* m_pApplication;

public:
	//##ModelId=431C34CC03CD
	CCommands();
	//##ModelId=431C34CD001F
	~CCommands();
	//##ModelId=431C34CD006D
	void SetApplicationObject(IApplication* m_pApplication);
	//##ModelId=431C34CD00AB
	IApplication* GetApplicationObject() { return m_pApplication; }
	//##ModelId=431C34CD00BB
	void UnadviseFromEvents();

	BEGIN_COM_MAP(CCommands)
		COM_INTERFACE_ENTRY(IDispatch)
		COM_INTERFACE_ENTRY(ICommands)
	END_COM_MAP()
	DECLARE_NOT_AGGREGATABLE(CCommands)

protected:
	// This class template is used as the base class for the Application
	//  event handler object and the Debugger event handler object,
	//  which are declared below.
	//##ModelId=431C34CE01A5
	template <class IEvents, const IID* piidEvents, const GUID* plibid,
		class XEvents, const CLSID* pClsidEvents>
	class XEventHandler :
		public CComDualImpl<IEvents, piidEvents, plibid>,
		public CComObjectRoot,
		public CComCoClass<XEvents, pClsidEvents>
	{
	public:
		BEGIN_COM_MAP(XEvents)
			COM_INTERFACE_ENTRY(IDispatch)
			COM_INTERFACE_ENTRY_IID(*piidEvents, IEvents)
		END_COM_MAP()
		DECLARE_NOT_AGGREGATABLE(XEvents)
		//##ModelId=431C34CE0232
		void Connect(IUnknown* pUnk)
		{ VERIFY(SUCCEEDED(AtlAdvise(pUnk, this, *piidEvents, &m_dwAdvise))); }
		//##ModelId=431C34CE0242
		void Disconnect(IUnknown* pUnk)
		{ AtlUnadvise(pUnk, *piidEvents, m_dwAdvise); }

		//##ModelId=431C34CE0245
		CCommands* m_pCommands;

	protected:
		//##ModelId=431C34CE0261
		DWORD m_dwAdvise;
	};

	// This object handles events fired by the Application object
	//##ModelId=431C34CE0290
	class XApplicationEvents : public XEventHandler<IApplicationEvents, 
		&IID_IApplicationEvents, &LIBID_TabBars, 
		XApplicationEvents, &CLSID_ApplicationEvents>
	{
	public:
		// IApplicationEvents methods
		//##ModelId=431C34CE02C1
		STDMETHOD(BeforeBuildStart)(THIS);
		//##ModelId=431C34CE030D
		STDMETHOD(BuildFinish)(THIS_ long nNumErrors, long nNumWarnings);
		//##ModelId=431C34CE033C
		STDMETHOD(BeforeApplicationShutDown)(THIS);
		//##ModelId=431C34CE037A
		STDMETHOD(DocumentOpen)(THIS_ IDispatch * theDocument);
		//##ModelId=431C34CE03B9
		STDMETHOD(BeforeDocumentClose)(THIS_ IDispatch * theDocument);
		//##ModelId=431C34CF000F
		STDMETHOD(DocumentSave)(THIS_ IDispatch * theDocument);
		//##ModelId=431C34CF003E
		STDMETHOD(NewDocument)(THIS_ IDispatch * theDocument);
		//##ModelId=431C34CF00BB
		STDMETHOD(WindowActivate)(THIS_ IDispatch * theWindow);
		//##ModelId=431C34CF0177
		STDMETHOD(WindowDeactivate)(THIS_ IDispatch * theWindow);
		//##ModelId=431C34CF01B5
		STDMETHOD(WorkspaceOpen)(THIS);
		//##ModelId=431C34CF01F4
		STDMETHOD(WorkspaceClose)(THIS);
		//##ModelId=431C34CF0232
		STDMETHOD(NewWorkspace)(THIS);
	};
	//##ModelId=431C34CF02CE
	typedef CComObject<XApplicationEvents> XApplicationEventsObj;
	//##ModelId=431C34CD00FB
	XApplicationEventsObj* m_pApplicationEventsObj;

	// This object handles events fired by the Application object
	//##ModelId=431C34CF02EE
	class XDebuggerEvents : public XEventHandler<IDebuggerEvents, 
		&IID_IDebuggerEvents, &LIBID_TabBars, 
		XDebuggerEvents, &CLSID_DebuggerEvents>
	{
	public:
		// IDebuggerEvents method
		//##ModelId=431C34CF033C
	    STDMETHOD(BreakpointHit)(THIS_ IDispatch * pBreakpoint);
	};
	//##ModelId=431C34CF036B
	typedef CComObject<XDebuggerEvents> XDebuggerEventsObj;
	//##ModelId=431C34CD011A
	XDebuggerEventsObj* m_pDebuggerEventsObj;
public:
	//##ModelId=431C34CD011E
	void ForceWindowReactivate();

	//##ModelId=431C34CD0167
  void DoHeaderFlip(CString cFullPath);//Switch file cpp/h
	//##ModelId=431C34CD01B5
  void DoOpenAsText(CString cFullName);
	//##ModelId=431C34CD01E4
  void DoSetCurrDir(CString cFullName); 
	//##ModelId=431C34CD0213
	BOOL PreaseFunctionDeclare(const CString & strFunction,CString & strFuncName,CStringArray & para,CString & strRetType);
public:
	//##ModelId=431C34CD0251
	STDMETHOD(OSOptions)(THIS);
	//##ModelId=431C34CD0271
	STDMETHOD(OSOpenDswInZip)(THIS);
	//##ModelId=431C34CD0281
	STDMETHOD(OSZipWorkspace)(THIS);
	//##ModelId=431C34CD029F
	STDMETHOD(OSInsertDiagram)(THIS);
	//##ModelId=431C34CD02AF
	STDMETHOD(OSFuncDesc)(THIS);
	//##ModelId=431C34CD02CE
	STDMETHOD(OSUnremark)(THIS);
	//##ModelId=431C34CE000F
	STDMETHOD(OSRemark)(THIS);
	//##ModelId=431C34CE001F
	STDMETHOD(OSBlockRemark)(THIS);
	//##ModelId=431C34CE003E
	STDMETHOD(OSOpenAsText)(THIS);
	//##ModelId=431C34CE005D
	STDMETHOD(OSSetCurrDir)(THIS);
	//##ModelId=431C34CE007D
	STDMETHOD(OSHeaderFlip)(THIS);
// ICommands methods
protected:
	//##ModelId=431C34CE00AB
  CString GetActiveDocumentName() const;
	//##ModelId=431C34CE00DA
  void FlashWindows(CComQIPtr<IWindows, &IID_IWindows>& pWindows, int cWindows, int iWindow) const;
	//##ModelId=431C34CE0128
	void OpenZippedWorkspace();
	//##ModelId=431C34CE0138
	BOOL ZipFolderToFile(LPCTSTR lpszFolder,LPCTSTR lpszOutputFile,LPCTSTR lpszFileTypes);
	//##ModelId=431C34CE0157
	void DoDiagram();
	//##ModelId=431C34CE0158
	BOOL EditDiagram(CString& sDiagram);
	//##ModelId=431C34CE0178
	BOOL FindDiagram(const CString& sText, int nLineSel);
};

//##ModelId=431C34CF0399
typedef CComObject<CCommands> CCommandsObj;


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_COMMANDS_H__8549F5E1_E75A_4BE5_9A59_B192929065D4__INCLUDED)
